HomeDirect Bank - Readme File - Hints and Tips
Welcome to HomeDirect! This Enterprise Java application uses J2EETM
technology, and is intended to be a design and development example to accompany the book
"Developing Enterprise Java Applications with J2EE and UML".
This document provides some hints and tips for the J2EE 1.3 version of this example.
- What This Example Intends to Show
This example is meant to be complete enough to show how J2EE 1.3 technology components
work together to form a web-based application. At the same time, the example is
intended to
be simple.
This example uses:
- Stateless Session Beans
- Entity Beans with Container-Managed Persistence (CMP)
- JSP pages
- JavaBeans to pass info to JSP pages
- Examples of both successful transactions, and failed ones that require a rollback
- Login Page
There are 4 pre-defined users in this example. They are:
- guest1
- guest2
- cumrysh
- kahmed
You can login using any of these accounts, and they all use the same password 'pass'.
Characters are always case sensitive for usernames and passwords. To add new users, accounts, or other new data, follow the instructions in
the next step.
- Pre-defined Tables and Data
The example comes with pre-defined tables and data that you seed the database
with during the install process. If you would like to add anything new or modify any of the
existing data, simply edit the script file found at %HomeDirect%\sql\homedirect.sql
.
Modify any of the INSERT statements that you see in this file, but be careful
when changing the table creation calls (entity beans might no longer work if the tables are significantly changed).
Run %HomeDirect%\sql\Resetdb.bat
for the changes to take effect. You will
need to start back at the Login page after this database reset is done.
- J2EE Server Window Trace
This example has been compiled with trace statements added to the code in
certain key locations. When you run the application, the output of these trace statements will
appear in the J2EE server window. The trace can help you to understand the flow of
the code, as well as indicate EJB behavior in different situations.
- Simulated Remote System Failures
This example has been designed to simulate successful
and failed transactions. Whenever you Transfer Funds or Pay Bills, a special method
is called to allocate a reference id for the transaction. This method is
designed to fail if the current time on your local machine indicates the seconds are
between 0 and 5. For example, if the current time is 12:15:06, the transaction will be successful.
If the same transaction is done at 12:16:04, you will get a failure (simulating a
problem with the remote system).
If the transaction succeeds, you will get back a valid reference id, and the trace
window should indicate that a COMMIT of the changes occurred for the EJBs involved
in the transaction. Account balances should reflect that the changes went through,
and a transaction record should appear.
Now take the same transaction, but in this case there was a simulated failure.
The logic is written such that most of the changes to the EJBs are done prior
to when the failure occurs. This way, you can see the rollback mechanism for these
EJBs in action. In this case, you shouldn't see a COMMIT in the trace, and
account balances should return to what they were before the transaction started.
- Processing and Storage of Currency Values
You might have noticed in the example code that currency is always stored as an integer
value in the underlying database instead of as a decimal value. This is to avoid rounding
errors that occur when Java decimal values are automatically converted for storage in the
database format, and vice versa. Certain databases appear more prone to such
conversion issues.
To get around this, we convert all dollar
values to pennies, and store this integer result instead. This adds a small amount of
conversion logic to change values back and forth between pennies and dollars, but the results
of transactions are always correct using this method.
It's expected a commercial databases will not have these conversion problems. A more involved solution would be to
store the decimal values as numerator and denominator
integer amounts instead, thus more easily allowing such conversions to work with any currency, not
just dollars and pennies.
- Table Name Changes and EJB QL
This release of J2EE makes use of the EJB Query Language to define finder methods for Entity
Beans. Along with this change, the findByPrimaryKey methods are now defined automatically by
the deployment tools as well. The default naming conventions used involve adding "EJBTable"
to the end of every table name, and the addition of quotes around all database table names and
column names. Unfortunately, at the time of this writing, the deployment tool provide no way to change these default
conventions.
For this reason, all table names and column names in this version of the example have been
changed to match these conventions.
- Container-Managed Persistence and the Sample J2EE Database
For the final release of J2EE 1.2.1, it was found that when working with Entity Beans
using container-managed persistence, the connection with the underlying database would
only work correctly if the tables you were dealing with had their fields defined in
alphabetical order. This problem appeared to only occur when using the
sample database shipped with J2EE 1.2.1.
It is not known if the beta 2 release of J2EE 1.3 addresses this issue. Keep this point in mind if you decide to expand on the database tables and Entity Beans
found in this example code. Commercial databases and enterprise application servers
are not expected to exhibit this problem.
Back to Install Instructions:
Install.html
Enter the HomeDirect Bank:
http://localhost:8000/homedirect/Login.jsp